home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / concur.com / SWITCHTA.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-09-26  |  3.4 KB  |  122 lines

  1.     name    switchta
  2. _TEXT    segment    byte public 'CODE'
  3. DGROUP    group    _DATA,_BSS
  4.     assume    cs:_TEXT,ds:DGROUP,ss:DGROUP
  5. _TEXT    ends
  6. _DATA    segment word public 'DATA'
  7. _d@    label    byte
  8. _DATA    ends
  9. _BSS    segment word public 'BSS'
  10. _b@    label    byte
  11. _BSS    ends
  12. _TEXT    segment    byte public 'CODE'
  13. ; Line 19
  14. _switchta    proc    near
  15. ; Line 20
  16. ; Line 21
  17.     mov    ax,word ptr DGROUP:_taskind
  18.     mov    dx,20
  19.     mul    dx
  20.     mov    bx,ax
  21.         pushf
  22.         pop     ax; get flags
  23.         mov     word ptr DGROUP:_jpr[bx],sp
  24.         mov     word ptr DGROUP:_jpr[bx+2],ss
  25.     mov    word ptr DGROUP:_jpr[bx+4],ax ;save flags
  26.     mov    word ptr DGROUP:_jpr[bx+10],bp
  27.     mov    word ptr DGROUP:_jpr[bx+12],di
  28.         mov     word ptr DGROUP:_jpr[bx+14],es
  29.     mov    word ptr DGROUP:_jpr[bx+16],si
  30.  
  31. ;save window
  32.         call    near ptr _wherey
  33.         mov     bx,word ptr DGROUP:_taskind
  34.         shl     bx,1
  35.         shl     bx,1
  36.         shl     bx,1
  37.         mov     byte ptr DGROUP:_windows[bx+4],al ;save cursor y
  38.         call    near ptr _wherex
  39.         mov     bx,word ptr DGROUP:_taskind
  40.         shl     bx,1
  41.         shl     bx,1
  42.         shl     bx,1
  43.         mov     byte ptr DGROUP:_windows[bx+5],al ;save cursor x
  44.  
  45.         mov     al, byte ptr DGROUP:__video+4; get task attr
  46.         mov     byte ptr DGROUP:_windows[bx+6],al; save task attr
  47.  
  48.         inc     word ptr DGROUP:_taskind; get next task
  49.  
  50.         mov     ax, word ptr DGROUP:_taskind
  51.         cmp     ax, word ptr DGROUP:_maxtask
  52.         jle     @2
  53.         mov     word ptr DGROUP:_taskind,0000; loop to task 0
  54.  
  55. @2:
  56.     mov    ax,word ptr DGROUP:_taskind
  57.     mov    dx,20
  58.     mul    dx
  59.     mov    bx,ax
  60.         cli     ; no interrupts during stack switching
  61.         mov     sp,word ptr DGROUP:_jpr[bx]; restore SP
  62.         mov     ss,word ptr DGROUP:_jpr[bx+2]; restore SS
  63.         mov     bp,word ptr DGROUP:_jpr[bx+10]; restore bp
  64.         mov     di,word ptr DGROUP:_jpr[bx+12]; restore di
  65.         mov     es,word ptr DGROUP:_jpr[bx+14]; restore es
  66.         mov     si,word ptr DGROUP:_jpr[bx+16]; restore si
  67.         sti     ;interrupts on again
  68.  
  69. @1:
  70.  
  71. ;get next window
  72.         push    bx
  73.         mov     bx,word ptr DGROUP:_taskind;
  74.         shl     bx,1
  75.         shl     bx,1
  76.         shl     bx,1
  77.         mov     al, byte ptr DGROUP:_windows[bx];
  78.         mov     byte ptr DGROUP:__video,al;
  79.         mov     al, byte ptr DGROUP:_windows[bx+1];
  80.         mov     byte ptr DGROUP:__video+1,al;
  81.         mov     al, byte ptr DGROUP:_windows[bx+2];
  82.         mov     byte ptr DGROUP:__video+2,al;
  83.         mov     al, byte ptr DGROUP:_windows[bx+3];
  84.         mov     byte ptr DGROUP:__video+3,al;
  85.  
  86.         mov     al, byte ptr DGROUP:_windows[bx+6];
  87.         mov     byte ptr DGROUP:__video+4,al; restore task attribute
  88.  
  89.         mov     al, byte ptr DGROUP:_windows[bx+4];
  90.         cbw
  91.         push    ax
  92.         mov     bx,word ptr DGROUP:_taskind;
  93.         shl     bx,1
  94.         shl     bx,1
  95.         shl     bx,1
  96.         mov     al,byte ptr DGROUP:_windows[bx+5]
  97.         cbw
  98.         push    ax
  99.         call    near ptr _gotoxy
  100.         pop     cx
  101.         pop     cx
  102.         pop     bx
  103.  
  104.  
  105.     ret
  106. _switchta    endp
  107. _TEXT    ends
  108. _BSS    segment word public 'BSS'
  109. _BSS    ends
  110. _DATA    segment word public 'DATA'
  111.         extrn _taskind:WORD, _jpr:WORD,_maxtask:WORD,_windows:WORD
  112.         extrn __video:WORD
  113. _s@    label    byte
  114. _DATA    ends
  115. _TEXT    segment    byte public 'CODE'
  116.     public    _switchta
  117.     extrn    _wherey:near
  118.         extrn   _wherex:near
  119.         extrn   _gotoxy:near
  120. _TEXT    ends
  121.     end
  122.